package com.bflow.api.constant.example.leave;

public interface ExampleLeaveConstant {

    /**
     * 请假类型: 事假=1; 病假=2; 休假=3;
     */
    enum LeaveType {
        COMPASSIONATE_LEAVE(1, "事假"),
        SICK_LEAVE(2, "病假"),
        VACATION_LEAVE(3, "休假"),
        ;

        private LeaveType(Integer code, String title) {
            this.code = code;
            this.title = title;
        }

        private Integer code;
        private String title;


        public Integer getCode() {
            return code;
        }

        public String getTitle() {
            return title;
        }

        /**
         * 获取
         *
         * @param code
         * @return
         */
        public static LeaveType get(Integer code) {
            if (code == null)
                return null;
            LeaveType[] statuses = values();
            for (LeaveType status : statuses) {
                if (status.getCode().equals(code)) {
                    return status;
                }
            }
            return null;
        }

        /**
         * 是否相等
         *
         * @param code
         * @return
         */
        public boolean eq(Integer code) {
            if (code == null)
                return false;
            return getCode().equals(code);
        }
    }

}
